<!doctype html>
<html>
	<head>
		<title>Lightweight-JSONP Example</title>
		<script src="../jsonp.js"></script>
	</head>
	<body>
		<ul id="example"></ul>
		<script>
			JSONP.init({
				error: function(ex){
					alert("Failed to load : " + ex.url);
				}
			});
		
			JSONP.get('sample-data.php', {param1:'123'}, function(data) {
				var example = document.getElementById('example'),
					item = null, li = null;
					
				if ( data && data.length > 0 ) {
					for ( var i in data ) {
						if ( data.hasOwnProperty(i) ) {
							item = data[i];
							li = document.createElement('li');
							li.innerHTML = "<h3>"+item.title+"</h3><p>"+item.description+"</p>";
							example.appendChild(li);
						}
					}				
				}
			});
			
			//Uncomment the following call will trigger the error callback and alert the failing url.
			//JSONP.get('not-existing-url');
		</script>
	</body>
</html>